import{bo as l,p as $}from"./DrFvzlh8agutd.js";import{a7 as g,a8 as h}from"./MpnPZlTSagutd.js";const n=$("assets"),d="application/octet-stream",x="unnamed",p="asset:";function y(t){if(t){let{protocol:s,pathname:e,searchParams:i}=new URL(t);n.assert(s===p,`Expected protocol '${p}', found '${s}`),e.startsWith("//")&&(e=`/${e.split("/").slice(3).join("/")}`);const a=e.split("/"),c=a[1];n.assert(c,"cid is missing");const o=+a[2];n.assert(typeof o=="number"&&!Number.isNaN(o),`idx is missing or wrong type: ${o}}`);const u=a.slice(3).join("/"),r=i.get("s")??0;n.assert(r,"Size is missing!");const f=i.get("t")??d,m=i.get("d");return n.assert(m,"Checksum is missing!"),{cid:c,idx:+o,size:+r,type:f,checksum:m,name:u}}}function z(t){return`asset:///${t.cid}/${t.idx}/${encodeURIComponent(t.name??"")}?s=${t.size}&t=${encodeURIComponent(t.type)}&d=${encodeURIComponent(t.checksum)}`}function k(t,s,e){return{...t,cid:s,idx:e}}async function w(t){const s=await l(t);if(s){const e=g(await h(s));return{bin:s,size:s.length,type:t.type||d,name:t.name??x,checksum:e}}}function C(t){return n.assert(t,"Expected asset"),`${t.cid}.${t.idx}`}function F(t){const s=y(t);if(s)return C(s)}export{z as a,w as b,k as c,F as d,C as e,y as f};